package data_forms

import (
	"gopkg.in/go-playground/validator.v9"
	"mime/multipart"
	"rabbit_love/src/model"
)

type GetDataRequest struct {
	Type model.DataType `query:"type" validate:"required"`

	Page  int `query:"page"`
	Limit int `query:"limit"`
}

func (reg *GetDataRequest) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}

type AddDataRequest struct {
	Pic   *multipart.FileHeader `form:"pic"`
	Type  model.DataType        `form:"type" validate:"required"`
	Title string                `form:"title"`
	Data  string                `form:"data"`
}

func (reg *AddDataRequest) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}

type UpdDataRequest struct {
	Pic    *multipart.FileHeader `form:"pic" json:"pic"`
	DataId int64                 `form:"dataId" json:"dataId" validate:"required"`
	Title  string                `form:"title"`
	Data   string                `form:"data"`
}

func (reg *UpdDataRequest) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}

type DelDataRequest struct {
	DataId int64 `json:"dataId"`
}

func (reg *DelDataRequest) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}
